<?php
class ControlPanel
{
  var $item;

  function ControlPanel()
  {
    $this->item = array();
  }

  function add($link, $title, $link2, $span = "", $checkbox = "", $separator = false)
  {
    $this->item[] = array($link, $title, $link2, $span, $checkbox, $separator);
  }

  function change($number = 0, $link, $title, $link2, $span = "", $checkbox = "", $separator = false)
  {
    $this->item[$number] = array($link, $title, $link2, $span, $checkbox, $separator);
  }

  function getNumber()
  {
    return count($this->item)-1;
  }

  function output()
  {
    $o = "<div class=\"cpanel\">\n";
    foreach($this->item as $i) {
      if($i[5]) {
        $o .= "<h2 class=\"clr\"><a href=\"".$i[0]."\" class=\"tooltip clr\" title=\"".$i[1]."\">".$i[2]."</a></h2>";
      } else {
        $o .= " <div style=\"float: left;\">\n  <div class=\"icon\">\n";
        if(!empty($i[4])) {
          $e = explode("|", $i[4]);
          $o .= "   <div style=\"position: absolute; z-index: 1; text-align: left;\">\n    <input type=\"checkbox\" name=\"".$e[0]."\" value=\"".$e[1]."\">   </div>\n";
        }
        $o .= "   <a href=\"".$i[0]."\" class=\"tooltip\" title=\"".$i[1]."\">\n";
        if(!empty($i[2])) {
          $o .= "    ".$i[2]."\n";
        }
        if(!empty($i[3])) {
          $o .= "    <span>".$i[3]."</span>\n";
        }
        $o .= "   </a>\n  </div>\n </div>\n";
      }
    }
    $o .= "</div>\n<div class=\"clr\"></div>\n";
    return $o;
  }
}
?>